function highlightNav() {
  const path = window.location.pathname.split('/').pop() || 'index.html';
  console.log('Current path:', path);

  document.querySelectorAll('.nav-item').forEach(item => {
    item.classList.remove('active');
  });

  const pageMap = {
    'index.html': 'navHome',
    'mall.html': 'navMall', 
    'points.html': 'navPoints',
    'profile.html': 'navProfile'
  };

  const activeId = pageMap[path];
  if (activeId) {
    document.getElementById(activeId)?.classList.add('active');
  }
}

// 多种触发方式确保执行
document.addEventListener('DOMContentLoaded', highlightNav);
window.addEventListener('load', highlightNav);
setTimeout(highlightNav, 300);